<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/user.css" rel="stylesheet">
    <script src="js/jquery-1.12.4.js"></script>
    <script src="js/jquery.validate.js"></script>
    <style>
    a{
     	text-decoration: none;
    	color: #A17567;
    }
    label.error{
    	color:red;
    }
    </style>
    <script>
        $(function() {
            $(".update").click(function(){
                $(".addressUpMsg").show();
                $("#address").val($(this).parents("tr").find("td").eq(0).text());
                $("#phone").val($(this).parents("tr").find("td").eq(1).text());
                $("#consignee").val($(this).parents("tr").find("td").eq(2).text());
                $("input[name=mid]").val($(this).attr("mid"));
            })
            $(".add").click(function(){
                $(".addressAddMsg").show();
            })
            $(".cancle").click(function(){
               $(this).parents("div").hide();
            })
            $("#addressAdd").validate({
                 rules:{
                	 address:{required:true},
            		 phone:{required:true},
                	 consignee:{required:true}
                 },
                 messages:{
                	 address:{required:"地址不能为空"},
                	 phone:{required:"电话不能为空"},
                	consignee:{required:"收货人不能为空"},
                 }
             })
             $("#addressUpdate").validate({
                 rules:{
                	 address:{required:true},
            		 phone:{required:true},
                	 consignee:{required:true}
                 },
                 messages:{
                	 address:{required:"地址不能为空"},
                	 phone:{required:"电话不能为空"},
                	consignee:{required:"收货人不能为空"},
                 }
             })
        })
    </script>
</head>
<body>
        <div class="header">
            <div class="container">
               <div class="nav">
					<p>
						<c:if test="${LoginUser==null}">
							<a href="login.html">登陆</a>&nbsp;&nbsp;
                    </c:if>
						<c:if test="${LoginUser!=null}">
							<a>${LoginUser.userName},欢迎你！</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                    <a href="cart.html">我的购物车</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                    <a href="login.html?out=t">注销</a>&nbsp;&nbsp;
                    </c:if>
						|&nbsp;&nbsp; <a href="register.html">注册</a>
					</p>
					<p>|&nbsp;符合人类进步的食品</p>
					<p>
						<a href="index.html">首页</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a
							href="productList.html">蛋糕名录</a>&nbsp;&nbsp;|&nbsp;&nbsp; <a
							href="user.html">用户中心</a>
					</p>
				</div>
            </div>
        </div>
        <div class="main">
            <div class="leftnav">
                <ul>
                    <h4>订单中心</h4>
                    <li><a href="">我的订单</a></li>
                    <li><a href="">收货地址</a></li>
                    <li><a href="">缺货登记</a></li>
                </ul>
                <ul>
                    <h4>用户中心</h4>
                    <li><a href="">用户信息</a></li>
                    <li><a href="">我的收藏</a></li>
                    <li><a href="">我的标签</a></li>
                    <li><a href="">我的留言</a></li>
                    <li><a href="">我的推荐</a></li>
                    <li><a href="">我的评论</a></li>
                </ul>
                <ul>
                    <h4>订单中心</h4>
                    <li><a href="">我的红包</a></li>
                    <li><a href="">跟踪包裹</a></li>
                    <li><a href="">资金管理</a></li>
                </ul>
            </div>
            <div class="message">
                <div class="usermessage">
                    <h3>你好<span>${user.userName}</span>,欢迎来到21cake官网</h3>
                    <table>
                        <tr>
                            <td>上次登录时间：<span>time</span></td>
                            <td>邮箱：<a href="">${user.email}</a></td>
                        </tr>
                        <tr>
                            <td>你目前是：<span>status</span></td>
                            <td>距离升级：你还差10000积分到vip</td>
                        </tr>
                    </table>
                    <p><a href=""><span class="glyphicon glyphicon-file"></span>用户中心公告</a></p>
                </div>
                <div class="useraddress">
                    <p><a class="add">新增收货地址</a></p>
                    <div class="addressAddMsg">
                        <form id="addressAdd" action="user.html" method="post">
                            <div class="form-group">
                                <label for="address" class="col-sm-2 control-label">收货地址</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control"  name="address">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="phone" class="col-sm-2 control-label">电话</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control"  name="phone">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="consignee" class="col-sm-2 control-label">收货人</label>
                                <div class="col-sm-10 ">
                                    <input type="text" class="form-control"  name="consignee">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <button type="submit" class="btn btn-default">提交</button>
                                    <button class="btn btn-default cancle">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <table class="table table-condensed">
                        <thead>
                            <tr>
                                <td>地址</td>
                                <td>电话</td>
                                <td>收货人</td>
                                <td>操作</td>
                            </tr>
                        </thead>
                        <tbody>
                        	<c:forEach var="a" items="${address}">
                        		<tr>
	                                <td width="40%">${a.address}</td>
	                                <td width="20%">${a.phone}</td>
	                                <td width="20%">${a.consignee}</td>
	                                <td>
	                                    <a class="update" mid="${a.id}">修改</a>
	                                    <a href="user.html?did=${a.id}" class="delete">删除</a>
	                                </td>
                            	</tr>
                        	</c:forEach>
                        <tbody>
                    </table>
                </div>
                <div class="addressUpMsg">
                    <form id="addressUpdate" method="post" action="user.html">
                        <input type="hidden" name="mid" value="">
                        <div class="form-group">
                            <label for="address" class="col-sm-2 control-label">收货地址</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="address" name="address">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="phone" class="col-sm-2 control-label">电话</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="phone"  name="phone">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="consignee" class="col-sm-2 control-label">收货人</label>
                            <div class="col-sm-10 ">
                                <input type="text" class="form-control" id="consignee"  name="consignee">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default">提交</button>
                                <button class="btn btn-default cancle">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="order">
                    <p>历史购买记录</p>
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <td>订单号</td>
                            <td>地址</td>
                            <td>收货人</td>
                            <td>总价</td>
                            <td>日期</td>
                            <td>状态</td>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="co" items="${cakeOrder}">
	                        <tr>
	                            <td width="10%">${co.oid}</td>
	                            <td width="50%">${co.address}</td>
	                            <td width="10%">${co.consignee}</td>
	                            <td width="10%">${co.totalPrice}</td>
	                            <td width="10%">${co.date}</td>
	                            <td width="10%">${co.status}</td>
	                        </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div class="footer">
            <hr>
            <div class="container">
                <div>
                    <p>©2005-2014&nbsp;21Cake官网版权所有，并保留所有权利</p>
                    <ul>
                        <li><a href="#">联系我们</a> &nbsp;</li>
                        <li><a href="#">售后流程</a> &nbsp;</li>
                        <li><a href="#">订购方式</a> &nbsp;</li>
                    </ul>
                </div>
            </div>
        </div>

    <script src="css/jquery-1.12.4.js"></script>
    <script src="css/bootstrap.min.js"></script>
</body>
</html>